#pragma once

#include "ProgramMain.hpp"
#include "ObjectCamera.hpp"
#include "FileChangeMonitor.hpp"

namespace common { namespace tokdoc { class Node; } }
class D3dEffect;
struct ShaderConstant;

namespace ShaderFractal {

class Screen : public IScreen, public IFileChangeEventListener
{
public:
	Screen();
	virtual ~Screen();
	
	virtual void Init();
	virtual void Update();
	virtual void Render3d();
	virtual void Render2d();
	virtual bool OnKeyDown(uint4 Key);
	virtual bool OnKeyUp(uint4 Key) { return false; }
	virtual bool OnChar(char Ch) { return false; }
	virtual bool OnMouseMove(const common::VEC2 &Pos);
	virtual bool OnMouseButton(const common::VEC2 &Pos, frame::MOUSE_BUTTON Button, frame::MOUSE_ACTION Action);
	virtual bool OnMouseWheel(const common::VEC2 &Pos, float Delta);

	virtual void OnFileChange(uint FileId);

private:
	ObjectCamera2d m_Camera;
	string m_ErrorMessage;
	string m_FilePath;
	scoped_ptr<D3dEffect, ReleasePolicy> m_Effect;
	string m_Technique;
	std::vector< shared_ptr< ShaderConstant > > m_ShaderConstants;
	bool m_FirstRender;

	void NewFractal();
	void MakeFractal(common::tokdoc::Node &doc);
	void ResetView();
};

} // namespace ShaderFractal
